<?php

/**
 * Copyright 2010 - 2013, Cake Development Corporation (http://cakedc.com)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright 2010 - 2013, Cake Development Corporation (http://cakedc.com)
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
/**
 * Usuarios Plugin Usuario Model
 *
 * @package Usuario
 * @subpackage Usuario.Model
 */
App::uses('AppModel', 'Model');

class Usuario extends UsuariosAppModel {

    /**
     * Name
     *
     * @var string
     */
    public $name = 'Usuario';
    public $table = 'usuarios';

    /**
     * All search fields need to be configured in the Model::filterArgs array.
     *
     * @var array
     * @link https://github.com/CakeDC/search
     */
    public $filterArgs = array(
        'usuarioname' => array('type' => 'like'),
        'email' => array('type' => 'value')
    );

    /**
     * Displayfield
     *
     * @var string $displayField
     */
    public $displayField = 'usuarioname';
    public $primaryKey = 'id';

    /**
     * Validation parameters
     *
     * @var array
     */
    public $validate = array(
        'usuarioname' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'required' => true, 'allowEmpty' => false,
                'message' => 'Please enter a usuarioname.'),
            'alpha' => array(
                'rule' => array('alphaNumeric'),
                'message' => 'The usuarioname must be alphanumeric.'),
            'unique_usuarioname' => array(
                'rule' => array('isUnique', 'usuarioname'),
                'message' => 'This usuarioname is already in use.'),
            'usuarioname_min' => array(
                'rule' => array('minLength', '3'),
                'message' => 'The usuarioname must have at least 3 characters.')),
        'email' => array(
            'isValid' => array(
                'rule' => 'email',
                'required' => true,
                'message' => 'Please enter a valid email address.'),
            'isUnique' => array(
                'rule' => array('isUnique', 'email'),
                'message' => 'This email is already in use.')),
        'password' => array(
            'on' => 'create',
            'rule' => array('minLength', '6'),
            'message' => 'The password must have at least 6 characters.',
            'required' => true,
            'allowEmpty' => false
        ),
    );

}
